//
//  NewVideoTableViewCell.m
//  UI_Project_A
//
//  Created by GH on 16/3/6.
//  Copyright © 2016年 GH. All rights reserved.
//

#import "NewVideoTableViewCell.h"
#import <UIImageView+WebCache.h>
#import <DKNightVersion.h>

@interface NewVideoTableViewCell ()

@property (nonatomic ,retain)UIView *viewOftemp;
@property (nonatomic ,retain)UILabel *timeLabel;
@property (nonatomic ,retain)UILabel *labelTitle;
@property (nonatomic ,retain)UILabel *labeldescription;
@property (nonatomic ,retain)UILabel *labelTime;
@property (nonatomic ,retain)UILabel *labelCount;
@property (nonatomic ,retain)NSString *url;
@property (nonatomic ,retain)NSString *strTime;


@property (nonatomic ,retain)UIImageView *imageCell;


@property (nonatomic ,retain)UIImageView *imageTime;
@property (nonatomic ,retain)UIImageView *imageCount;
@property (nonatomic ,retain)UIImageView *imagePlay;



@end


@implementation NewVideoTableViewCell

- (void) dealloc {
    
    [_strTime release];
    [_imagePlay release];
    [_imageCount release];
    [_imageTime release];
    [_labelCount release];
    [_labelTime release];
    [_labelTitle release];
    [_timeLabel release];
    [super dealloc];
    
}




- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self createView];
    }
    
    return self;
    
}




- (void)passModelOfNewPush:(ModelOfNewPush *)model {

    self.url = model.mp4_url;
    
    
    //    [self addAVplayer];
    
    
    self.labelTitle.text = model.title;
    self.labelTitle.font = [UIFont systemFontOfSize:20];
    
    self.labeldescription.text = model.des;
    self.labeldescription.font = [UIFont systemFontOfSize:15];
    self.labeldescription.textColor = [UIColor grayColor];
    
    self.labelTime.text = model.ptime;
    
    self.labelCount.text = model.playCount.description;
    [self.imageCell sd_setImageWithURL:[NSURL URLWithString:model.cover]];
    

    self.labelTime.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    self.labelTitle.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);

    self.labelCount.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    



}



- (void)createView {
    
    
    self.viewOftemp = [[UIView alloc] init];
    [self.contentView addSubview:self.viewOftemp];
    [self.viewOftemp release];
    //    self.viewOftemp.backgroundColor = [UIColor redColor];
    self.viewOftemp.layer.masksToBounds = YES;
    self.viewOftemp.layer.cornerRadius = 5;
    self.viewOftemp.layer.borderWidth = 1;
    self.viewOftemp.layer.borderColor = [UIColor lightGrayColor].CGColor;
    self.viewOftemp.layer.shadowOffset = CGSizeMake(0, 1);
    self.viewOftemp.layer.shadowOpacity = 0.2;
    
    
    
    //title
    self.labelTitle = [[UILabel alloc] init];
    [self.viewOftemp addSubview:self.labelTitle];
    [self.labelTitle release];
    
    //description
    self.labeldescription = [[UILabel alloc] init];
    [self.viewOftemp addSubview:self.labeldescription];
    [self.labeldescription release];
    
    
    //time
    self.labelTime = [[UILabel alloc] init];
    [self.viewOftemp addSubview:self.labelTime];
    [self.labelTime release];
    
    
    //
    self.labelCount = [[UILabel alloc] init];
    [self.viewOftemp addSubview:self.labelCount];
    [self.labelCount release];
    
    
    
    self.imageCell = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@""]];
    [self.viewOftemp addSubview:self.imageCell];
    [self.imageCell release];
    
    
    
    self.imageTime = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"time"]];
    [self.viewOftemp addSubview:self.imageTime];
    [self.imageTime release];
    
    
    self.imageCount = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bofang4"]];
    [self.viewOftemp addSubview:self.imageCount];
    [self.imageCount release];
    
    self.imagePlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bofang6"]];
    [self.viewOftemp addSubview:self.imagePlay];
    [self.imagePlay release];
    
    
    
}


- (void)layoutSubviews {
    [super layoutSubviews];
    self.viewOftemp.frame = CGRectMake(10, 10, self.frame.size.width - 20, self.frame.size.height - 20);
    
    
    
    //title
    self.labelTitle.frame = CGRectMake( 20, self.frame.size.height/2 +30, self.superview.frame.size.width - 40, 50);
    
    //description
    self.labeldescription.frame = CGRectMake(20, self.frame.size.height /2 +80, self.frame.size.width - 40, 22);
    
    //labeltime
    self.labelTime.frame = CGRectMake(50, self.frame.size.height /2 +110, 185, 20);
    
    //labelcount
    self.labelCount.frame = CGRectMake(270, self.frame.size.height / 2 +110, 50, 20);
    
    //
    self.imageCell.frame = CGRectMake(0, 0, self.superview.frame.size.width - 20,self.frame.size.height/2+30);
    
    self.imagePlay.frame = CGRectMake(0, 0, 60, 60);
    self.imagePlay.center = self.imageCell.center;
    
    
    
    
    self.imageTime.frame = CGRectMake(20, self.frame.size.height /2 +110, 20, 20);
    self.imageCount.frame = CGRectMake(235, self.frame.size.height / 2 +110, 20, 20);
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
